package com.dap.cas.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2017/12/13
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2017/12/13
 */
@ConfigurationProperties(prefix = "cas")
//@Configuration
public class SpringCasConfigProperties {
    // cas server地址
    private String casServerUrlPrefix;
    // Cas登录页面地址
    private String casServerLoginUrl;
    // Cas登出页面地址
    private String casServerLogoutUrl;
    // 当前工程对外提供的服务地址
    private String clientUrlPrefix;

    // casFilter UrlPattern
    private String casFilterUrlPattern ;

    // 登录成功地址
    private final  String loginSuccessUrl = "/home";
    // 权限认证失败跳转地址
    private String unauthorizedUrl;
    // 登录地址
    private String loginUrl;

    // 登出地址（casserver启用service跳转功能，需在webapps\cas\WEB-INF\cas.properties文件中启用cas.logout
    // .followServiceRedirects=true）
    private String logoutUrl;

    public String getCasServerUrlPrefix() {
        return casServerUrlPrefix;
    }

    public void setCasServerUrlPrefix(String casServerUrlPrefix) {
        this.casServerUrlPrefix = casServerUrlPrefix;
    }

    public String getCasServerLoginUrl() {
        return casServerLoginUrl;
    }

    public void setCasServerLoginUrl(String casServerLoginUrl) {
        this.casServerLoginUrl = casServerLoginUrl;
    }

    public String getCasServerLogoutUrl() {
        return casServerLogoutUrl;
    }

    public void setCasServerLogoutUrl(String casServerLogoutUrl) {
        this.casServerLogoutUrl = casServerLogoutUrl;
    }

    public String getClientUrlPrefix() {
        return clientUrlPrefix;
    }

    public void setClientUrlPrefix(String clientUrlPrefix) {
        this.clientUrlPrefix = clientUrlPrefix;
    }

    public String getCasFilterUrlPattern() {
        return casFilterUrlPattern;
    }

    public void setCasFilterUrlPattern(String casFilterUrlPattern) {
        this.casFilterUrlPattern = casFilterUrlPattern;
    }

    public String getLoginSuccessUrl() {
        return loginSuccessUrl;
    }

    //public void setLoginSuccessUrl(String loginSuccessUrl) {
    //    this.loginSuccessUrl = loginSuccessUrl;
    //}

    public String getUnauthorizedUrl() {
        return unauthorizedUrl;
    }

    public void setUnauthorizedUrl(String unauthorizedUrl) {
        this.unauthorizedUrl = unauthorizedUrl;
    }

    //login-url: ${cas.cas-server-login-url}?service=${cas.client-url-prefix}${cas
    // .cas-filter-url-pattern}
    public String getLoginUrl() {
        return getCasServerLoginUrl()+"?service="+getClientUrlPrefix()+getCasFilterUrlPattern();
    }

    public void setLoginUrl(String loginUrl) {
        this.loginUrl = loginUrl;
    }

    //logout-url: ${cas.cas-server-logout-url}?service=${cas.client-url-prefix}
    public String getLogoutUrl() {
        return getCasServerLogoutUrl()+"?service="+getClientUrlPrefix();
    }

    public void setLogoutUrl(String logoutUrl) {
        this.logoutUrl = logoutUrl;
    }
}
